package com.wit.witmg.api;


import com.wit.witmg.service.ITStockService;
import com.wit.witmg.service.ITSupplierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author bob
 * @since 2025-01-14
 */
@RestController
@RequestMapping("supplier")
@Api(tags = "供应商API")
public class SupplierController {
    @Resource
    private ITSupplierService service;

    @ApiOperation("添加")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

    @ApiOperation("获取")
    @PostMapping("get")//tp返回数组；oid部门编号，返回oid以参数开头并包含参数的数据；bn返回单条数据（前端支持二维码识别），id返回单条数据，常用于连表查询；
    public Object get(HttpServletRequest request,
                      @RequestParam(value = "id",required = false) Integer id,
                      @RequestParam(value = "tp",required = false,defaultValue = "0") Integer tp,
                      @RequestParam(value = "lab",required = false) String lab,
                      @RequestParam(value = "oid",required = false) String oid,
                      @RequestParam(value = "bn",required = false) String bn)
    {
        return service.get(request,id,tp,lab,oid,bn);
    }

    @ApiOperation("删除")
    @PostMapping("del")
    public Object del(HttpServletRequest request,
                      @RequestParam("id") Integer id) {
        return service.del(request,id);
    }
}
